<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0"  lay-title="计费规则">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card layui-tab layui-tab-brief" style="margin: 0;">
                    <ul class="layui-tab-title">
                        <li class="layui-this" value="1" click_num="1">校园版计费规则</li>
                        <li value="2" click_num="1">酒店版计费规则</li>
                    </ul>
                    <div class="layui-card-body layui-tab-content hxr-card-body" style="padding: 15px;">
                        <div class="layui-tab-item layui-show" id="bonusset">
                            <div class="layui-card">
                                <div class="layui-card-body">
                                    <div>
                                        <button class="layui-btn layuiadmin-btn-list" data-type="batchdel1">删除</button>
                                        <button class="layui-btn layuiadmin-btn-list" data-type="add1">添加</button>
                                    </div>
                                    <table class="layui-hide" id="list-select-table1" lay-filter="list-select-table1"></table>
                                    <div id="list-toolbar1" style="display: none;">
                                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
                                    </div>
                                    <script type="text/html" id="rule_desc">
                                        {{# layui.each(JSON.parse(d.rule_desc),function(i,item){ }} [{{item.start_week}}~{{item.end_week}}的{{item.start_time}}~{{item.end_time}}({{# if(item.status==1){ }}满{{item.time_money}}元免费{{#  } else{ }}{{item.time_money}}元/小时{{#  } }})] {{# }) }}
                                    </script>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <div class="layui-card-body">
                                <div>
                                    <button class="layui-btn layuiadmin-btn-list" data-type="batchdel2">删除</button>
                                    <button class="layui-btn layuiadmin-btn-list" data-type="add2">添加</button>
                                </div>
                                <table class="layui-hide" id="list-select-table2" lay-filter="list-select-table2"></table>
                                <div id="list-toolbar2" style="display: none;">
                                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
                                </div>
                                <script type="text/html" id="use_val">
                                    {{# layui.each(JSON.parse(d.use_val),function(i,item){ }}
                                    [{{item.hours}}小时--{{item.price}}元]
                                    {{# }) }}
                                </script>
                            </div>
                        </div>

                    </div>


                </div>
            </div>
        </div>
    </div>
</div>
</div>
<style type="text/css">
    #drawingsset .layui-form-label{
        width: 150px;
    }

    #break_set .layui-form-label{
        width: 150px;
    }
    #commission .layui-form-label{
        width: 150px;
    }
    #benefit .layui-form-label{
        width: 150px;
    }
    #applets .layui-form-label{
        width: 150px;
    }
    #opens .layui-form-label{
        width: 150px;
    }
    #drawset .layui-form-label{
        width: 150px;
    }
    #recharge .layui-form-label{
        width: 150px;
    }
    #rechargeset .layui-btn-danger{
        display: inline-block !important;
    }

</style>
<script>
    var formurl='time_money/time_moneyform',formarea=['600px', '600px'];
    layui.use(['table', 'form','element'], function() {
        var table = layui.table,
            form = layui.form,
            $ = layui.$,
            element = layui.element;

        layui.admin.initlist(table,'device/rule_list',195,[[
            {type:'checkbox',fixed:'left'}
            ,{field:'device_rule_id', title: 'ID', width:60}
            ,{field:'rule_name', title: '计费规则名称', width:150}
            ,{field:'rule_desc', title: '计费规则详情', minWidth:200,templet:'#rule_desc'}
            ,{field:'start_cost', title: '起步费用(元)', width: 110}
            ,{field:'real_cost', title: '实时扣费(元)', width: 110}
            ,{field:'create_time', title: '创建时间', width: 200}
            //,{field:'cost_status', title:'是否包时段', width:100, templet: '#list-tableF', unresize: true}
            ,{title:'操作', toolbar: '#list-toolbar1', width:150,fixed:'right'}
        ]],'#list-select-table1');
        //监听表格表单操作
        //监听表格操作事件
        table.on('tool(list-select-table1)', function(obj){console.log(obj)
            var data = obj.data;
            //删除
            if(obj.event === 'del'){
                layer.confirm('确定删除'+data.rule_name+'?', function(index){
                    layui.admin.delF(table,'device/rule_delete',{device_rule_id:data.device_rule_id},'list-select-table1');
                });
            } else if(obj.event === 'edit'){//编辑
                layui.admin.pupF('编辑计费',formarea,formurl,2,data)
            }
        });
        var active = {
            //多行删除
            batchdel1:function(){
                layui.admin.delsF(table,'device/rule_delete','device_rule_id','list-select-table1')
            }
            //添加
            ,add1: function(othis){
                layui.admin.pupF('添加计费',formarea,formurl,1,{})
            }
        };
//操作dom
        $('.layui-btn.layuiadmin-btn-list').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        element.on('tab()', function(){
            var item_val=$(this).attr('value')
            if (item_val==1){//
                var formurl='time_money/time_moneyform',formarea=['600px', '600px'];
                if ($(this).attr('click_num')!=1) return false;
                $(this).attr('click_num',2);
            }else if (item_val==2){//
                var formurl='hotel_time_money/time_moneyform',formarea=['600px', '600px'];
                if ($(this).attr('click_num')!=1) return false;
                $(this).attr('click_num',2);
                layui.admin.initlist(table,'device/hotel_rule_list',195,[[
                    {type:'checkbox',fixed:'left'}
                    ,{field:'hotel_id', title: 'ID', width:60}
                    ,{field:'activity_name', title: '计费规则名称', width:150}
                    ,{field:'use_val', title: '计费规则详情', minWidth:200,templet:'#use_val'}
                    ,{field:'create_time', title: '创建时间', width: 200}
                    //,{field:'cost_status', title:'是否包时段', width:100, templet: '#list-tableF', unresize: true}
                    ,{title:'操作', toolbar: '#list-toolbar2', width:150,fixed:'right'}
                ]],'#list-select-table2');
                //监听表格操作事件
                table.on('tool(list-select-table2)', function(obj){
                    var data = obj.data;
                    //删除
                    if(obj.event === 'del'){
                        layer.confirm('确定删除'+data.activity_name+'?', function(index){
                            layui.admin.delF(table,'device/hotel_rule_delete',{hotel_id:data.hotel_id},'list-select-table2');
                        });
                    } else if(obj.event === 'edit'){//编辑
                        layui.admin.pupF('编辑计费',formarea,formurl,2,data)
                    }
                });
                //监听行双击事件
                /* table.on('rowDouble(list-table)', function(obj){
                    //查看详情
                    if($('.time_moneylist').length){
                        layui.admin.pupF('计费详情',formarea,formurl,3,obj.data);
                    }

                }); */
                var active = {
                    //多行删除
                    batchdel2:function(){
                        layui.admin.delsF(table,'device/hotel_rule_delete','hotel_id','list-select-table2')
                    }
                    //添加
                    ,add2: function(othis){
                        layui.admin.pupF('添加计费',formarea,formurl,1,{})
                    }
                };
                //操作dom
                $('.layui-btn.layuiadmin-btn-list').on('click', function(){
                    var type = $(this).data('type');
                    active[type] ? active[type].call(this) : '';
                });


            }

            //   return false;

        });
    })
</script>